MaxVal = 1000000

n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())
ans = 0

# c[d] - number of elements = d
c = [0] * (MaxVal + 1)

# f[d] - number of pairs with first element = d
f = [0] * (MaxVal + 1)


for i in range(n - 1, -1, -1):
    divisors = []
    r = 1
    while r * r <= a[i]:
        if a[i] % r == 0:
            divisors.append(r)
            div = a[i] // r
            if div != r:
                divisors.append(div)
        r += 1
    f_ai = f[a[i]]
    for d in divisors:
        ans += f[d]
        f_ai += c[d]
    f[a[i]] = f_ai
    c[a[i]] += 1

print(ans)
